﻿package mortal.game.view.guild.redPack
{
    import Message.Game.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class RedPackRobResultPanel extends GSprite
    {
        private var _resultTxt:GTextFiled;
        private var _tipTxt:GImageBitmap;
        private var _buttomTxt:GTextFiled;
        private var _priceIcon:GBitmap;
        private var _hasGetRedPackIcon:GImageBitmap;
        private var _sRedEvnvelopInfo:SRedEnvelopeInfo;

        public function RedPackRobResultPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.RedPackMoneyBg, 109, 342, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.RedPackSimpleTxt_1, 123, 110, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap("", 112, 152, this));
            this._tipTxt = UIFactory.gImageBitmap("", 102, 152, this, null);
            var _loc_1:* = GlobalStyle.textFormatHuang2.center();
            _loc_1.size = 18;
            _loc_1.bold = true;
            this._resultTxt = UIFactory.gTextField("", 128, 357, 167, 40, this, _loc_1);
            _loc_1.size = 14;
            this._buttomTxt = UIFactory.gTextField("", 50, 465, 320, 50, this, _loc_1);
            this._buttomTxt.multiline = true;
            this._priceIcon = UIFactory.gBitmap("", 245, 360, this);
            this._hasGetRedPackIcon = UIFactory.gImageBitmap(ImagesConst.MonthInvestGetSuccess, 203, 210, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._resultTxt.dispose(param1);
            this._resultTxt = null;
            this._tipTxt.dispose(param1);
            this._tipTxt = null;
            this._buttomTxt.dispose(param1);
            this._buttomTxt = null;
            this._hasGetRedPackIcon.dispose(param1);
            this._hasGetRedPackIcon = null;
            this._priceIcon.dispose(param1);
            this._priceIcon = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateType(param1:SRedEnvelopeInfo = null) : void
        {
            var _loc_3:String = null;
            var _loc_4:String = null;
            this._sRedEvnvelopInfo = param1;
            var _loc_2:* = Cache.instance.redPackCache.redPackState;
            if (_loc_2 == RedPackStateType.HasNotGet)
            {
                this._resultTxt.text = Language.getString(21504);
                this._buttomTxt.htmlText = Language.getString(21505);
                this._tipTxt.imgUrl = ImagesConst.RedPackTxt_4;
                this._priceIcon.bitmapData = null;
            }
            else if (_loc_2 == RedPackStateType.HasGot)
            {
                _loc_3 = Cache.instance.role.entityInfo.name;
                for (_loc_4 in this._sRedEvnvelopInfo.robInfos)
                {
                    
                    if (_loc_3 == _loc_4)
                    {
                        if (this._sRedEvnvelopInfo.type == 0)
                        {
                            this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGoldBind));
                            this._buttomTxt.htmlText = Language.getStringByParam(21506, (this._sRedEvnvelopInfo.robInfos[_loc_4] as SRobRedInfo).money);
                        }
                        else if (this._sRedEvnvelopInfo.type == 1)
                        {
                            this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGold));
                            this._buttomTxt.htmlText = Language.getStringByParam(21507, (this._sRedEvnvelopInfo.robInfos[_loc_4] as SRobRedInfo).money);
                        }
                        else if (this._sRedEvnvelopInfo.type == 2)
                        {
                            this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGoldBind));
                            this._buttomTxt.htmlText = Language.getStringByParam(35638, (this._sRedEvnvelopInfo.robInfos[_loc_4] as SRobRedInfo).money);
                        }
                        this._resultTxt.text = (this._sRedEvnvelopInfo.robInfos[_loc_4] as SRobRedInfo).money.toString();
                        this._resultTxt.x = 128;
                        this._resultTxt.y = 357;
                    }
                }
                this._tipTxt.imgUrl = ImagesConst.RedPackTxt_3;
            }
            return;
        }// end function

        public function updateResult(param1:SRedEnvelopeInfo) : void
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:String = null;
            this._sRedEvnvelopInfo = param1;
            var _loc_2:* = Cache.instance.role.entityInfo.name;
            for (_loc_5 in this._sRedEvnvelopInfo.robInfos)
            {
                
                if (_loc_2 == _loc_5)
                {
                    _loc_3 = (this._sRedEvnvelopInfo.robInfos[_loc_5] as SRobRedInfo).money;
                    break;
                }
            }
            if (_loc_3)
            {
                var _loc_6:* = RedPackStateType.HasGot;
                Cache.instance.redPackCache.redPackState = RedPackStateType.HasGot;
                _loc_4 = _loc_6;
            }
            else
            {
                var _loc_6:* = RedPackStateType.HasNotGet;
                Cache.instance.redPackCache.redPackState = RedPackStateType.HasNotGet;
                _loc_4 = _loc_6;
            }
            if (_loc_4 == RedPackStateType.HasGot)
            {
                this._hasGetRedPackIcon.visible = true;
                this._resultTxt.text = _loc_3.toString();
                this._tipTxt.imgUrl = ImagesConst.RedPackTxt_3;
                if (this._sRedEvnvelopInfo.type == 0)
                {
                    this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGoldBind));
                    this._buttomTxt.htmlText = Language.getStringByParam(21506, (this._sRedEvnvelopInfo.robInfos[_loc_5] as SRobRedInfo).money);
                }
                else if (this._sRedEvnvelopInfo.type == 1)
                {
                    this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGold));
                    this._buttomTxt.htmlText = Language.getStringByParam(21507, (this._sRedEvnvelopInfo.robInfos[_loc_5] as SRobRedInfo).money);
                }
                else if (this._sRedEvnvelopInfo.type == 2)
                {
                    this._priceIcon.bitmapData = GlobalClass.getBitmapData(GameDefConfig.instance.getEPrictUnitImg(EPriceUnit._EPriceUnitGoldBind));
                    this._buttomTxt.htmlText = Language.getStringByParam(35638, (this._sRedEvnvelopInfo.robInfos[_loc_5] as SRobRedInfo).money);
                }
            }
            else if (_loc_4 == RedPackStateType.HasNotGet)
            {
                this._hasGetRedPackIcon.visible = false;
                this._tipTxt.imgUrl = ImagesConst.RedPackTxt_4;
                this._resultTxt.text = Language.getString(21504);
                this._priceIcon.bitmapData = null;
                if (this._sRedEvnvelopInfo.type == 0)
                {
                    this._buttomTxt.htmlText = Language.getString(21505);
                }
                else if (this._sRedEvnvelopInfo.type == 1)
                {
                    this._buttomTxt.htmlText = Language.getString(21508);
                }
                else if (this._sRedEvnvelopInfo.type == 2)
                {
                    this._buttomTxt.htmlText = Language.getString(35640);
                }
            }
            return;
        }// end function

    }
}
